/**
 * 获取二叉树的叶子节点数
 */

 function treeLeaf(bt) {
    if (bt === null) return 0
    if (bt.leftChild === null && bt.rightChild === null) return 1 
    return (treeLeaf(bt.leftChild) + treeLeaf(bt.rightChild))
 }

 const TreeNode = require('./binary_tree_chain')

/**
 * 二叉树的遍历
 */

 const a = new TreeNode('A')
 const b = new TreeNode('B')
 const c = new TreeNode('C')
 const d = new TreeNode('D')
 const e = new TreeNode('E')
 const f = new TreeNode('F')
 const g = new TreeNode('G')
 const h = new TreeNode('H')
 
 
 a.leftChild = b
 a.rightChild = c
 b.leftChild = d
 b.rightChild = e
 e.leftChild = g
 e.rightChild = h
 c.leftChild = f

console.log( treeLeaf(a) )